<template>
  <div class="bind-merchant-container">
    <!-- 页面标题 -->
    <div class="page-header">
      <h2 class="page-title">
        <i class="el-icon-plus"></i>
        绑定商家
      </h2>
      <p class="page-description">推广商家签约，上传商家信息进行审核</p>
    </div>

    <!-- 业务员信息展示 -->
    <div class="salesman-info">
      <el-card>
        <div slot="header" class="card-header">
          <i class="el-icon-user"></i>
          <span>业务员信息</span>
        </div>
        <div class="salesman-info-content">
          <div class="info-item">
            <div class="info-icon">
              <i class="el-icon-tickets"></i>
            </div>
            <div class="info-content">
              <div class="info-label">业务员编码</div>
              <div class="info-value">{{ salesmanInfo.salesmanNo || '-' }}</div>
            </div>
          </div>
          <div class="info-item">
            <div class="info-icon">
              <i class="el-icon-user-solid"></i>
            </div>
            <div class="info-content">
              <div class="info-label">业务员姓名</div>
              <div class="info-value">{{ salesmanInfo.name || '-' }}</div>
            </div>
          </div>
          <div class="info-item">
            <div class="info-icon">
              <i class="el-icon-phone"></i>
            </div>
            <div class="info-content">
              <div class="info-label">联系电话</div>
              <div class="info-value">{{ salesmanInfo.phone || '-' }}</div>
            </div>
          </div>
        </div>
      </el-card>
    </div>

    <!-- 商家信息表单 -->
    <div class="merchant-form">
      <el-card>
        <div slot="header" class="card-header">
          <i class="el-icon-s-shop"></i>
          <span>商家信息</span>
        </div>

        <el-form :model="form" :rules="rules" ref="form" label-width="120px">
          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="商家名称" prop="merchantName">
                <el-input v-model="form.merchantName" placeholder="请输入商家名称"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="商家手机号" prop="merchantPhone">
                <el-input v-model="form.merchantPhone" placeholder="请输入商家手机号" maxlength="11"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="24">
              <el-form-item label="商家地址" prop="merchantAddress">
                <el-input v-model="form.merchantAddress" placeholder="请输入商家地址"></el-input>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="身份证号" prop="idNo">
                <el-input v-model="form.idNo" placeholder="请输入身份证号" maxlength="18"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="锁定用户上限" prop="lockNumLimit">
                <el-input-number v-model="form.lockNumLimit" :min="1" :max="1000" style="width: 100%"></el-input-number>
              </el-form-item>
            </el-col>
          </el-row>

          <!-- 证件上传区域 -->
          <el-divider content-position="left">
            <i class="el-icon-upload"></i>
            <span style="margin-left: 8px;">证件上传</span>
          </el-divider>

          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="身份证正面" prop="idCardUrl">
                <div class="upload-wrapper">
                  <el-upload
                    class="upload-container"
                    :action="uploadUrl"
                    :headers="uploadHeaders"
                    :on-success="handleIdCardSuccess"
                    :before-upload="beforeUpload"
                    :on-progress="(event, file) => { uploading.idCard = true }"
                    :show-file-list="false">
                    <div class="upload-area" v-if="!form.idCardUrl">
                      <i class="el-icon-plus upload-icon"></i>
                      <div class="upload-text">点击上传</div>
                      <div class="upload-tip">JPG/PNG，不超过2MB</div>
                    </div>
                    <div class="upload-preview" v-else>
                      <el-image
                        :src="form.idCardUrl"
                        fit="cover"
                        :preview-src-list="[form.idCardUrl]"
                        class="preview-image">
                        <div slot="error" class="image-slot-error">
                          <i class="el-icon-picture-outline"></i>
                          <div class="error-text">图片加载失败</div>
                        </div>
                      </el-image>
                      <div class="upload-mask" @click.stop>
                        <i class="el-icon-delete" @click.stop="form.idCardUrl = ''" title="删除图片"></i>
                      </div>
                    </div>
                  </el-upload>
                </div>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="身份证背面" prop="idCardBackUrl">
                <div class="upload-wrapper">
                  <el-upload
                    class="upload-container"
                    :action="uploadUrl"
                    :headers="uploadHeaders"
                    :on-success="handleIdCardBackSuccess"
                    :before-upload="beforeUpload"
                    :on-progress="(event, file) => { uploading.idCardBack = true }"
                    :show-file-list="false">
                    <div class="upload-area" v-if="!form.idCardBackUrl">
                      <i class="el-icon-plus upload-icon"></i>
                      <div class="upload-text">点击上传</div>
                      <div class="upload-tip">JPG/PNG，不超过2MB</div>
                    </div>
                    <div class="upload-preview" v-else>
                      <el-image
                        :src="form.idCardBackUrl"
                        fit="cover"
                        :preview-src-list="[form.idCardBackUrl]"
                        class="preview-image">
                        <div slot="error" class="image-slot-error">
                          <i class="el-icon-picture-outline"></i>
                          <div class="error-text">图片加载失败</div>
                        </div>
                      </el-image>
                      <div class="upload-mask" @click.stop>
                        <i class="el-icon-delete" @click.stop="form.idCardBackUrl = ''" title="删除图片"></i>
                      </div>
                    </div>
                  </el-upload>
                </div>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row :gutter="20">
            <el-col :span="12">
              <el-form-item label="营业执照" prop="certificateUrl">
                <div class="upload-wrapper">
                  <el-upload
                    class="upload-container"
                    :action="uploadUrl"
                    :headers="uploadHeaders"
                    :on-success="handleCertificateSuccess"
                    :before-upload="beforeUpload"
                    :on-progress="(event, file) => { uploading.certificate = true }"
                    :show-file-list="false">
                    <div class="upload-area" v-if="!form.certificateUrl">
                      <i class="el-icon-plus upload-icon"></i>
                      <div class="upload-text">点击上传</div>
                      <div class="upload-tip">JPG/PNG，不超过2MB</div>
                    </div>
                    <div class="upload-preview" v-else>
                      <el-image
                        :src="form.certificateUrl"
                        fit="cover"
                        :preview-src-list="[form.certificateUrl]"
                        class="preview-image">
                        <div slot="error" class="image-slot-error">
                          <i class="el-icon-picture-outline"></i>
                          <div class="error-text">图片加载失败</div>
                        </div>
                      </el-image>
                      <div class="upload-mask" @click.stop>
                        <i class="el-icon-delete" @click.stop="form.certificateUrl = ''" title="删除图片"></i>
                      </div>
                    </div>
                  </el-upload>
                </div>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="卫生许可证" prop="hygienicUrl">
                <div class="upload-wrapper">
                  <el-upload
                    class="upload-container"
                    :action="uploadUrl"
                    :headers="uploadHeaders"
                    :on-success="handleHygienicSuccess"
                    :before-upload="beforeUpload"
                    :on-progress="(event, file) => { uploading.hygienic = true }"
                    :show-file-list="false">
                    <div class="upload-area" v-if="!form.hygienicUrl">
                      <i class="el-icon-plus upload-icon"></i>
                      <div class="upload-text">点击上传</div>
                      <div class="upload-tip">JPG/PNG，不超过2MB</div>
                    </div>
                    <div class="upload-preview" v-else>
                      <el-image
                        :src="form.hygienicUrl"
                        fit="cover"
                        :preview-src-list="[form.hygienicUrl]"
                        class="preview-image">
                        <div slot="error" class="image-slot-error">
                          <i class="el-icon-picture-outline"></i>
                          <div class="error-text">图片加载失败</div>
                        </div>
                      </el-image>
                      <div class="upload-mask" @click.stop>
                        <i class="el-icon-delete" @click.stop="form.hygienicUrl = ''" title="删除图片"></i>
                      </div>
                    </div>
                  </el-upload>
                </div>
              </el-form-item>
            </el-col>
          </el-row>

          <el-form-item>
            <div class="form-actions">
              <el-button type="primary" size="medium" @click="handleSubmit" :loading="submitting" icon="el-icon-check">
                提交审核
              </el-button>
              <el-button size="medium" @click="handleReset" icon="el-icon-refresh">
                重置表单
              </el-button>
            </div>
          </el-form-item>
        </el-form>
      </el-card>
    </div>
  </div>
</template>

<script>
import { submitMerchantAudit, getSalesmanInfo, uploadFile } from '@/api/salesman/bind-merchant'

export default {
  name: 'BindMerchant',
  data() {
    return {
      // 业务员信息
      salesmanInfo: {
        salesmanNo: '',
        name: '',
        phone: ''
      },

      // 表单数据
      form: {
        merchantName: '',
        merchantPhone: '',
        merchantAddress: '',
        idNo: '',
        idCardUrl: '',
        idCardBackUrl: '',
        certificateUrl: '',
        hygienicUrl: '',
        lockNumLimit: 100
      },

      // 表单验证规则
      rules: {
        merchantName: [
          { required: true, message: '请输入商家名称', trigger: 'blur' }
        ],
        merchantPhone: [
          { required: true, message: '请输入商家手机号', trigger: 'blur' },
          { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }
        ],
        merchantAddress: [
          { required: true, message: '请输入商家地址', trigger: 'blur' }
        ],
        idNo: [
          { required: true, message: '请输入身份证号', trigger: 'blur' },
          { pattern: /^[1-9]\d{5}(18|19|20)\d{2}((0[1-9])|(1[0-2]))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/, message: '请输入正确的身份证号', trigger: 'blur' }
        ],
        idCardUrl: [
          { required: true, message: '请上传身份证正面', trigger: 'change' }
        ],
        idCardBackUrl: [
          { required: true, message: '请上传身份证背面', trigger: 'change' }
        ],
        certificateUrl: [
          { required: true, message: '请上传营业执照', trigger: 'change' }
        ],
        hygienicUrl: [
          { required: true, message: '请上传卫生许可证', trigger: 'change' }
        ]
      },

      // 上传相关
      uploadUrl: '/agg/file/upload',
      uploadHeaders: {
        'token': this.$store.state.user.token
      },
      uploading: {
        idCard: false,
        idCardBack: false,
        certificate: false,
        hygienic: false
      },

      // 提交状态
      submitting: false
    }
  },

  created() {
    this.loadSalesmanInfo()
  },

  methods: {
    // 加载业务员信息
    async loadSalesmanInfo() {
      try {
        Logger.log('=== 获取业务员信息 ===')
        const response = await getSalesmanInfo()
        Logger.log('业务员信息响应:', response.data)

        if (response.code === 0 && response.data) {
          const userData = response.data
          this.salesmanInfo = {
            salesmanNo: userData.salesmanNo || '',  // 业务员编码
            name: userData.name || '',
            phone: userData.phone || ''
          }
          Logger.log('✅ 业务员信息获取成功:', this.salesmanInfo)
        } else {
          throw new Error(response.data?.msg || '获取业务员信息失败')
        }
      } catch (error) {
        Logger.error('❌ 获取业务员信息失败:', error)
        // 如果获取失败，使用store中的默认值
        this.salesmanInfo = {
          salesmanNo: this.$store.state.user.salesmanNo || this.$store.state.user.id || '',
          name: this.$store.state.user.name || '',
          phone: this.$store.state.user.phone || ''
        }
        this.$message.warning('获取业务员信息失败，使用默认信息')
      }
    },

    // 上传前验证
    beforeUpload(file) {
      const isJPG = file.type === 'image/jpeg' || file.type === 'image/png'
      const isLt2M = file.size / 1024 / 1024 < 2

      if (!isJPG) {
        this.$message.error('上传图片只能是 JPG/PNG 格式!')
        return false
      }
      if (!isLt2M) {
        this.$message.error('上传图片大小不能超过 2MB!')
        return false
      }
      return true
    },

    // 处理图片URL - 如果是相对路径，转换为完整路径
    getImageUrl(url) {
      if (!url) return ''
      // 如果已经是完整URL（以http或https开头），直接返回
      if (url.startsWith('http://') || url.startsWith('https://')) {
        return url
      }
      // 如果是相对路径（以/开头），可能是OSS路径或本地路径，直接返回让浏览器处理
      if (url.startsWith('/')) {
        return url
      }
      // 其他情况，尝试添加/profile前缀（本地存储）
      return `/profile/${url}`
    },

    // 身份证正面上传成功
    handleIdCardSuccess(response) {
      this.uploading.idCard = false
      Logger.log('身份证正面上传响应:', response)
      if (response && response.code === 0) {
        // 优先使用data字段，如果没有则使用msg字段（兼容不同接口返回格式）
        const imageUrl = response.data || response.msg || ''
        if (imageUrl) {
          this.form.idCardUrl = this.getImageUrl(imageUrl)
          this.$message.success('身份证正面上传成功')
        } else {
          this.$message.error('上传成功但未返回图片URL')
        }
      } else {
        this.$message.error('身份证正面上传失败: ' + (response?.msg || '未知错误'))
      }
    },

    // 身份证背面上传成功
    handleIdCardBackSuccess(response) {
      this.uploading.idCardBack = false
      Logger.log('身份证背面上传响应:', response)
      if (response && response.code === 0) {
        // 优先使用data字段，如果没有则使用msg字段（兼容不同接口返回格式）
        const imageUrl = response.data || response.msg || ''
        if (imageUrl) {
          this.form.idCardBackUrl = this.getImageUrl(imageUrl)
          this.$message.success('身份证背面上传成功')
        } else {
          this.$message.error('上传成功但未返回图片URL')
        }
      } else {
        this.$message.error('身份证背面上传失败: ' + (response?.msg || '未知错误'))
      }
    },

    // 营业执照上传成功
    handleCertificateSuccess(response) {
      this.uploading.certificate = false
      Logger.log('营业执照上传响应:', response)
      if (response && response.code === 0) {
        // 优先使用data字段，如果没有则使用msg字段（兼容不同接口返回格式）
        const imageUrl = response.data || response.msg || ''
        if (imageUrl) {
          this.form.certificateUrl = this.getImageUrl(imageUrl)
          this.$message.success('营业执照上传成功')
        } else {
          this.$message.error('上传成功但未返回图片URL')
        }
      } else {
        this.$message.error('营业执照上传失败: ' + (response?.msg || '未知错误'))
      }
    },

    // 卫生许可证上传成功
    handleHygienicSuccess(response) {
      this.uploading.hygienic = false
      Logger.log('卫生许可证上传响应:', response)
      if (response && response.code === 0) {
        // 优先使用data字段，如果没有则使用msg字段（兼容不同接口返回格式）
        const imageUrl = response.data || response.msg || ''
        if (imageUrl) {
          this.form.hygienicUrl = this.getImageUrl(imageUrl)
          this.$message.success('卫生许可证上传成功')
        } else {
          this.$message.error('上传成功但未返回图片URL')
        }
      } else {
        this.$message.error('卫生许可证上传失败: ' + (response?.msg || '未知错误'))
      }
    },

    // 提交表单
    handleSubmit() {
      this.$refs.form.validate(async (valid) => {
        if (valid) {
          this.submitting = true
          try {
            // 构建提交数据 - 按照后端API规范
            const submitData = {
              name: this.form.merchantName,                    // 商家名称
              phone: this.form.merchantPhone,                  // 商家联系电话
              idNo: this.form.idNo,                           // 商家身份证号
              address: this.form.merchantAddress,             // 商家地址
              salesmanNo: this.salesmanInfo.salesmanNo,       // 业务员编码（业务员自己的编号）
              regionId: this.$store.state.user.regionId || 1, // 区域代理ID（从用户信息获取）
              lockNumLimit: this.form.lockNumLimit,           // 商家锁定用户数量上限
              idCardUrl: this.form.idCardUrl,                 // 身份证正面照
              idCardBackUrl: this.form.idCardBackUrl,         // 身份证背面照
              certificateUrl: this.form.certificateUrl,       // 营业执照
              hygienicUrl: this.form.hygienicUrl              // 卫生许可证
            }

            Logger.log('=== 提交商家审核API请求调试 ===')
            Logger.log('提交数据:', submitData)

            const response = await submitMerchantAudit(submitData)
            Logger.log('商家审核提交响应:', response.data)

            if (response.code === 0) {
              this.$message.success('商家信息提交成功，等待审核')
              this.handleReset()
            } else {
              this.$message.error(response.data?.msg || '提交失败')
            }

          } catch (error) {
            Logger.error('提交商家审核失败:', error)
            this.$message.error('提交失败，请重试')
          } finally {
            this.submitting = false
          }
        }
      })
    },

    // 重置表单
    handleReset() {
      this.$refs.form.resetFields()
      this.form.lockNumLimit = 100
      // 重新加载业务员信息
      this.loadSalesmanInfo()
    }
  }
}
</script>

<style scoped>
.bind-merchant-container {
  padding: 20px;
  background-color: #f5f5f5;
  min-height: 100vh;
}

.page-header {
  margin-bottom: 20px;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  color: #303133;
  margin: 0 0 8px 0;
  display: flex;
  align-items: center;
}

.page-description {
  color: #606266;
  margin: 0;
  font-size: 14px;
}

.salesman-info {
  margin-bottom: 20px;
}

.salesman-info ::v-deep .el-card {
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  border: 1px solid #e4e7ed;
}

.salesman-info .card-header {
  display: flex;
  align-items: center;
}

.salesman-info .card-header i {
  margin-right: 8px;
  color: #409EFF;
  font-size: 18px;
}

.salesman-info-content {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 8px 0;
  flex-wrap: wrap;
}

.salesman-info-content .info-item {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #f5f7fa 0%, #fafbfc 100%);
  border-radius: 8px;
  border: 1px solid #e4e7ed;
  transition: all 0.3s ease;
  cursor: default;
}

.salesman-info-content .info-item:hover {
  border-color: #409EFF;
  box-shadow: 0 2px 8px rgba(64, 158, 255, 0.15);
  transform: translateY(-2px);
}

.salesman-info-content .info-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: linear-gradient(135deg, #409EFF 0%, #66b1ff 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 16px;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(64, 158, 255, 0.25);
}

.salesman-info-content .info-icon i {
  font-size: 24px;
  color: #fff;
}

.salesman-info-content .info-content {
  flex: 1;
  min-width: 0;
}

.salesman-info-content .info-label {
  font-size: 13px;
  color: #909399;
  margin-bottom: 6px;
  font-weight: 400;
}

.salesman-info-content .info-value {
  font-size: 16px;
  color: #303133;
  font-weight: 600;
  word-break: break-all;
  line-height: 1.4;
}

.merchant-form {
  margin-bottom: 20px;
}

.merchant-form ::v-deep .el-card {
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  border: 1px solid #e4e7ed;
}

.card-header {
  font-weight: 600;
  color: #303133;
  font-size: 16px;
  display: flex;
  align-items: center;
}

.card-header i {
  margin-right: 8px;
  color: #409EFF;
  font-size: 18px;
}

.el-form-item {
  margin-bottom: 22px;
}

.el-form-item ::v-deep .el-form-item__label {
  font-weight: 500;
  color: #606266;
  padding-bottom: 0;
}

.el-divider {
  margin: 30px 0 20px 0;
  background-color: #e4e7ed;
}

.el-divider__text {
  color: #409EFF;
  font-weight: 600;
  font-size: 15px;
  padding: 0 16px;
  background-color: #fff;
}

/* 上传组件样式优化 */
.upload-wrapper {
  width: 100%;
}

.upload-container {
  width: 100%;
}

.upload-area {
  width: 100%;
  height: 180px;
  border: 2px dashed #d9d9d9;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: #fafafa;
  position: relative;
  overflow: hidden;
}

.upload-area:hover {
  border-color: #409EFF;
  background-color: #f0f9ff;
}

.upload-icon {
  font-size: 48px;
  color: #8c939d;
  margin-bottom: 12px;
  transition: all 0.3s ease;
}

.upload-area:hover .upload-icon {
  color: #409EFF;
  transform: scale(1.1);
}

.upload-text {
  color: #606266;
  font-size: 14px;
  margin-bottom: 8px;
  font-weight: 500;
}

.upload-tip {
  color: #909399;
  font-size: 12px;
}

.upload-preview {
  position: relative;
  width: 100%;
  height: 180px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #e4e7ed;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.preview-image {
  width: 100%;
  height: 100%;
  display: block;
}

.image-slot-error {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  background-color: #f5f7fa;
  color: #909399;
}

.image-slot-error i {
  font-size: 48px;
  margin-bottom: 8px;
  color: #c0c4cc;
}

.image-slot-error .error-text {
  font-size: 14px;
  color: #909399;
}

.upload-mask {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  cursor: pointer;
}

.upload-preview:hover .upload-mask {
  opacity: 1;
}

.upload-mask i {
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: rgba(245, 108, 108, 0.85);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.upload-mask i:hover {
  transform: scale(1.15);
  background-color: #f56c6c;
  box-shadow: 0 2px 8px rgba(245, 108, 108, 0.5);
}

/* 表单操作按钮 */
.form-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid #e4e7ed;
}

.form-actions .el-button {
  min-width: 120px;
  height: 40px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.form-actions .el-button--primary {
  background-color: #409EFF;
  border-color: #409EFF;
}

.form-actions .el-button--primary:hover {
  background-color: #66b1ff;
  border-color: #66b1ff;
}

.form-actions .el-button:not(.el-button--primary) {
  border-color: #dcdfe6;
}

.form-actions .el-button:not(.el-button--primary):hover {
  border-color: #409EFF;
  color: #409EFF;
  background-color: #ecf5ff;
}

/* 输入框样式优化 */
::v-deep .el-input__inner {
  border-radius: 4px;
  transition: all 0.3s ease;
}

::v-deep .el-input__inner:focus {
  border-color: #409EFF;
}

::v-deep .el-input-number {
  width: 100%;
}

::v-deep .el-input-number .el-input__inner {
  text-align: left;
}

/* 卡片阴影优化 */
::v-deep .el-card {
  transition: box-shadow 0.3s ease;
}

::v-deep .el-card:hover {
  box-shadow: 0 4px 16px 0 rgba(0, 0, 0, 0.12);
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .bind-merchant-container {
    padding: 16px;
  }

  .salesman-info-content {
    gap: 16px;
  }

  .salesman-info-content .info-item {
    min-width: 180px;
    padding: 14px 18px;
  }
}

@media (max-width: 768px) {
  .bind-merchant-container {
    padding: 12px;
  }

  .page-title {
    font-size: 20px;
  }

  .salesman-info-content {
    flex-direction: column;
    gap: 12px;
  }

  .salesman-info-content .info-item {
    min-width: 100%;
    padding: 14px 16px;
  }

  .salesman-info-content .info-icon {
    width: 42px;
    height: 42px;
    margin-right: 12px;
  }

  .salesman-info-content .info-icon i {
    font-size: 20px;
  }

  .salesman-info-content .info-value {
    font-size: 15px;
  }

  .el-col {
    margin-bottom: 16px;
  }

  .upload-area,
  .upload-preview {
    height: 160px;
  }

  .form-actions {
    flex-direction: column;
  }

  .form-actions .el-button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .bind-merchant-container {
    padding: 10px;
  }

  .page-title {
    font-size: 18px;
  }

  .salesman-info-content .info-item {
    padding: 12px 14px;
  }

  .salesman-info-content .info-icon {
    width: 38px;
    height: 38px;
    margin-right: 10px;
  }

  .salesman-info-content .info-icon i {
    font-size: 18px;
  }

  .salesman-info-content .info-label {
    font-size: 12px;
    margin-bottom: 4px;
  }

  .salesman-info-content .info-value {
    font-size: 14px;
  }

  .upload-area,
  .upload-preview {
    height: 140px;
  }
}
</style>
